package br.eng.eliseu.gwt.gestaoWeb.server.guice;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.servlet.GuiceServletContextListener;


public class WEBGuiceConfig extends GuiceServletContextListener {

	@Override
	protected final Injector getInjector() {
		return Guice.createInjector(
				new WEBJPAModule(),
				new WEBServletModule()
				);
	}

	
	@Override
	public void contextInitialized(ServletContextEvent servletContextEvent) {
//		super.contextInitialized(servletContextEvent);

		ServletContext sc = servletContextEvent.getServletContext();
		sc.setAttribute("injector", getInjector());
	}

}